﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using Gacn.ControleAlunos.Library.Entities;
using Gacn.ControleAlunos.Library.Business;
using System.Data;

namespace Gacn.ControleAlunos.WebApplication.Services
{
    /// <summary>
    /// Summary description for Aluno
    /// </summary>
    [WebService(Namespace = "http://hp.gacn.com.br/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class Aluno : System.Web.Services.WebService
    {
        
        [WebMethod][ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<AlunoEntity> EnviaTodosOsAlunos()
        {
            return AlunoBiz.GetAllAlunoEntity();
        }

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<AlunoEntity> GetAlunosPorNomeOuID(string nomeOuIDAluno)
        {
            int IDAluno = 0;
            bool b = int.TryParse(nomeOuIDAluno, out IDAluno);

            if (b)
                return AlunoBiz.GetAlunoEntityPorID(IDAluno);
            else
                return AlunoBiz.GetAlunosPorNome(nomeOuIDAluno);
        }
    }
}
